Check if the chooser implementation supports the "show-number" property
authorEmmanuele Bassi <ebassi@gnome.org>
Tue, 11 Jul 2006 20:40:47 +0000 (20:40 +0000)
committerEmmanuele Bassi <ebassi@src.gnome.org>
Tue, 11 Jul 2006 20:40:47 +0000 (20:40 +0000)
2006-07-11  Emmanuele Bassi  <ebassi@gnome.org>

* gtk/gtkrecentchooser.c (gtk_recent_chooser_set_show_numbers),
(gtk_recent_chooser_get_show_numbers): Check if the chooser
implementation supports the "show-number" property and use a
meaningful warning in case it doesn't; tell developers not to
use these functions.

ChangeLog
ChangeLog.pre-2-10
gtk/gtkrecentchooser.c

index 046e36b0ed4e567cab3720364aff2eccf3ce0743..72555385f088f0559fe021b6efcffcd0a8a7f40e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-07-11  Emmanuele Bassi  <ebassi@gnome.org>
+
+       * gtk/gtkrecentchooser.c (gtk_recent_chooser_set_show_numbers),
+       (gtk_recent_chooser_get_show_numbers): Check if the chooser
+       implementation supports the "show-number" property and use a
+       meaningful warning in case it doesn't; tell developers not to
+       use these functions.
+
 2006-07-10  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c:
index 046e36b0ed4e567cab3720364aff2eccf3ce0743..72555385f088f0559fe021b6efcffcd0a8a7f40e 100644 (file)
@@ -1,3 +1,11 @@
+2006-07-11  Emmanuele Bassi  <ebassi@gnome.org>
+
+       * gtk/gtkrecentchooser.c (gtk_recent_chooser_set_show_numbers),
+       (gtk_recent_chooser_get_show_numbers): Check if the chooser
+       implementation supports the "show-number" property and use a
+       meaningful warning in case it doesn't; tell developers not to
+       use these functions.
+
 2006-07-10  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c:
index 7435d76689bd118488651968e4e69237c706a772..fe2c39dc19134b0682eb4127449c47ed8b4ab146 100644 (file)
@@ -497,13 +497,36 @@ gtk_recent_chooser_get_show_tips (GtkRecentChooser *chooser)
  *
  * Whether to show recently used resources prepended by a unique number.
  *
+ * Do not use this function: use gtk_recent_chooser_menu_set_show_numbers()
+ * instead.
+ *
  * Since: 2.10
  */
 void
 gtk_recent_chooser_set_show_numbers (GtkRecentChooser *chooser,
                                     gboolean          show_numbers)
 {
+  GParamSpec *pspec;
+  
   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
+
+  /* This is the result of a minor screw up: the "show-numbers" property
+   * was removed from the GtkRecentChooser interface, but the accessors
+   * remained in the interface API; now we need to check whether the
+   * implementation of the RecentChooser interface has a "show-numbers"
+   * boolean property installed before accessing it, and avoid an
+   * assertion failure using a more graceful warning.  This should really
+   * go away as soon as we can break API and remove these accessors.
+   */
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (chooser),
+                                       "show-numbers");
+  if (!pspec || pspec->value_type != G_TYPE_BOOLEAN)
+    {
+      g_warning ("Choosers of type `%s' do not support showing numbers",
+                G_OBJECT_TYPE_NAME (chooser));
+
+      return;
+    }
   
   g_object_set (chooser, "show-numbers", show_numbers, NULL);
 }
@@ -515,6 +538,9 @@ gtk_recent_chooser_set_show_numbers (GtkRecentChooser *chooser,
  * Returns whether @chooser should display recently used resources
  * prepended by a unique number.
  *
+ * Do not use this function: use gtk_recent_chooser_menu_get_show_numbers()
+ * instead.
+ *
  * Return value: %TRUE if the recent chooser should show display numbers,
  *   %FALSE otherwise.
  *
@@ -523,9 +549,20 @@ gtk_recent_chooser_set_show_numbers (GtkRecentChooser *chooser,
 gboolean
 gtk_recent_chooser_get_show_numbers (GtkRecentChooser *chooser)
 {
+  GParamSpec *pspec;
   gboolean show_numbers;
   
   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
+
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (chooser),
+                                       "show-numbers");
+  if (!pspec || pspec->value_type != G_TYPE_BOOLEAN)
+    {
+      g_warning ("Choosers of type `%s' do not support showing numbers",
+                G_OBJECT_TYPE_NAME (chooser));
+
+      return FALSE;
+    }
   
   g_object_get (chooser, "show-numbers", &show_numbers, NULL);